
<!-- The template to display files available for upload -->
<script id="template-upload" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
    <tr class="template-upload fade">
        <td>
            <span class="preview"></span>
        </td>
        <td>
            <p class="name">{%=file.name%}</p>
            {% if (file.error) { %}
                <div><span class="label label-danger">Error</span> {%=file.error%}</div>
            {% } %}
        </td>
        <td>
            <p class="size">{%=o.formatFileSize(file.size)%}</p>
            {% if (!o.files.error) { %}
                <div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="progress-bar progress-bar-success" style="width:0%;"></div></div>
            {% } %}
        </td>
        <td>
            {% if (!o.files.error && !i && !o.options.autoUpload) { %}
                <button class="btn btn-primary start">
                    <i class="glyphicon glyphicon-upload"></i>
                    <span>Start</span>
                </button>
            {% } %}
            {% if (!i) { %}
                <button class="btn btn-warning cancel">
                    <i class="glyphicon glyphicon-ban-circle"></i>
                    <span>Cancel</span>
                </button>
            {% } %}
        </td>
    </tr>
{% } %}
</script>

<!-- The template to display files available for download -->
<script id="template-download" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
    <tr class="template-download fade">
        <td>
            <span class="preview">
                {% if (file.thumbnailUrl) { %}
                    <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" data-gallery><img src="{%=file.thumbnailUrl%}"></a>
                {% } %}
            </span>
        </td>
        <td>
            <p class="name">
                {% if (file.url) { %}
                    <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnailUrl?'data-gallery':''%}>{%=file.name%}</a>
                {% } else { %}
                    <span>{%=file.name%}</span>
                {% } %}
            </p>
            {% if (file.error) { %}
                <div><span class="label label-danger">Error</span> {%=file.error%}</div>
            {% } %}
        </td>
        <td>
            <span class="size">{%=o.formatFileSize(file.size)%}</span>
        </td>
        <td>
            {% if (file.deleteUrl) { %}
                <button class="btn btn-danger delete" data-type="{%=file.deleteType%}" data-url="{%=file.deleteUrl%}"{% if (file.deleteWithCredentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
                    <i class="glyphicon glyphicon-trash"></i>
                    <span>Delete</span>
                </button>
                <input type="checkbox" name="delete" value="1" class="toggle">
            {% } else { %}
                <button class="btn btn-warning cancel">
                    <i class="glyphicon glyphicon-ban-circle"></i>
                    <span>Cancel</span>
                </button>
            {% } %}
        </td>
    </tr>
{% } %}
</script>
                <?php
                $judul = '';
                $link = '';
                $jenis = array('1' => 'rumah', '2' => 'apartemen', '3' => 'tanah', '4' => 'ruko dan kios',
                    '5' => 'ruang kantor', '6' => 'indekost', '7' => 'hotel dan villa', '8' => 'gudang', '9' => 'lainnya');
                $beli = array('1' => 'dijual', '2' => 'disewa', '3' => 'dicari');

                $sertifikasi = array('1' => 'SHM-Sertifikat', '2' => 'Hak Milik', '3' => 'HGB', '4' => 'lainnya(PPJB,adat,dll)');
                $furnitur = array('1' => 'Fully furnished', '2' => 'Semi furnished', '3' => 'Unfurnished');
                $fasilitas = array('1' => 'kolam renang', '2' => 'gym', '3' => 'sauna', '4' => 'tennis court',
                    '5' => 'jogging track', '6' => 'function room', '7' => 'children play ground', '8' => 'ATM', '9' => 'mini market',
                    '10' => 'library', '11' => 'shopping center', '12' => 'entertainment center');

                $provinsi = array('jakarta' => 'DKI Jakarta', 'jateng' => 'Jawa Tengah', 'jabar' => 'Jawa Barat');

                // if ($isUpdate == TRUE) {
                //     $judul = 'Ubah Properti';
                //     $link = site_url('admin/listing/update_listing/' . $properti_id);
                //     $submit = 'Update';
                // } else {
                    $judul = 'Tambah Properti';
                    $link = site_url('admin/listing/tambah_listing');
                    $submit = 'Tambah';
                // }

                // $sewaBeli = "";
                // $sewaBeli = $sewa_beli;
                /*function generate_option($array=array(), $sel='') {
                    $x = '';
                    foreach ($array as $key => $val) {
                        if ($key == $sel) {
                            $selected = set_select('option', $sel, TRUE);
                        } else {
                            $selected = set_select('option', $sel);
                        }
                        echo '<option value="' . $key . '" ' . $selected . '>' . $val . '</option>';
                    }
                    return $array[$x];
                }

                function generate_input($type='', $array=array(), $name='', $sel='') {
                    if ($type == 'radio') {
                        foreach ($array as $key => $val) {
                            echo '<input type="' . $type . '" name="' . $name . '" value="' . $key . '"/>' . $val . '&nbsp;';
                        }
                    } else {
                        foreach ($array as $key => $val) {
                            echo '<input type="' . $type . '" name="' . $key . '" value="' . $key . '"/>' . $val . '&nbsp;';
                        }
                    }
                }*/
                function generate_option($array=array(), $sel='') {
                    $x = '';
                    foreach ($array as $key => $val) {
                        if($sel == $key){
                            echo '<option value="' . $key . '" selected="">' . $val . '</option>';
                        } else {
                            echo '<option value="' . $key . '">' . $val . '</option>';
                        }
                    }
                    return $array[$x];
                }

                function generate_input($span='', $type='', $array=array(), $name='', $a=array(), $isUpdate="") {
                    $checked = "";
                    if ($type == 'radio') {
                        foreach ($array as $key => $val) {
                            if($a == $key){ 
                                echo '<div class="' . $span . '"><label class="radio checked"><input data-toggle="radio" type="' . $type . '" name="' . $name . '" value="' . $key . '">' . $val . '&nbsp;</label></div>';                            
                            } else {
                                echo '<div class="' . $span . '"><label class="radio unchecked"><input data-toggle="radio" type="' . $type . '" name="' . $name . '" value="' . $key . '">' . $val . '&nbsp;</label></div>';
                            }
                        }
                    } else {
                        foreach ($array as $key => $val) {
                            echo '<input type="' . $type . '" name="' . $key . '" value="' . $key . '"/>' . $val . '&nbsp;';
                        }
                    }
                }
                ?>
<div class="page dashboard">
    <div class="container">
        <div class="row">
            <ul class="span3 nav nav-list menu-sidebar">
                <div style="margin-bottom:10px;" >Selamat Datang, <?php echo anchor(site_url('admin/dashboard'), $this->session->userdata('username')); ?></div>
                <li class=""><?php echo anchor(site_url('admin/profil/form_update_user/'.$this->session->userdata('user_id')),'Edit Profil');?></li>
                <li class="aktif"><?php echo anchor(site_url('admin/listing'),'Kelola Listing');?></li>
                <?php if($level_user == 1){ ?>
                <li class=""><?php echo anchor(site_url('admin/profil'),'Kelola Agen');?></li>
                <li class=""><?php echo anchor(site_url('admin/artikel'),'Kelola Artikel');?></li>
                <li class=""><?php echo anchor('http://localhost/artyproperty/editor/properti_baru.php','Kelola Properti Baru');?></li>
                <?php } ?>
            </ul>
            <div class="span9 detail-profil">
                <ul class="nav nav-tabs" id="myTab">
                    <li><a>Informasi Dasar</a></li>
                    <li><a>Informasi Tambahan</a></li>
                    <li class="active"><a data-toggle="tab">Galeri Properti</a></li>
                </ul>
                <legend><h5>Galeri</h5></legend>
                <form id="fileupload" action="<?php echo $link; ?>" method="POST" enctype="multipart/form-data">

                            <!-- Redirect browsers with JavaScript disabled to the origin page -->
                            <noscript><input type="hidden" name="redirect" value="http://blueimp.github.io/jQuery-File-Upload/"></noscript>
                            <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
                            <div class="row fileupload-buttonbar">
                                <div class="col-lg-7">
                                    <!-- The fileinput-button span is used to style the file input field as button -->
                                    <span class="btn btn-success fileinput-button">
                                        <i class="glyphicon glyphicon-plus"></i>
                                        <span>.. Tambah Files..</span>
                                        <input type="file" name="img[]" multiple>
                                    </span>
                                    <button type="submit" class="btn btn-primary start">
                                        <i class="glyphicon glyphicon-upload"></i>
                                        <span>Start upload</span>
                                    </button>
                                    <button type="reset" class="btn btn-warning cancel">
                                        <i class="glyphicon glyphicon-ban-circle"></i>
                                        <span>Cancel upload</span>
                                    </button>
                                    <button type="button" class="btn btn-danger delete">
                                        <i class="glyphicon glyphicon-trash"></i>
                                        <span>Delete</span>
                                    </button>
                                    <input type="checkbox" class="toggle">
                                    <!-- The loading indicator is shown during file processing -->
                                    <span class="fileupload-loading"></span>
                                </div>
                                <!-- The global progress information -->
                                <div class="col-lg-5 fileupload-progress fade">
                                    <!-- The global progress bar -->
                                    <div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
                                        <div class="progress-bar progress-bar-success" style="width:0%;"></div>
                                    </div>
                                    <!-- The extended global progress information -->
                                    <div class="progress-extended">&nbsp;</div>
                                </div>
                            </div>
                            <!-- The table listing the files available for upload/download -->
                            <table role="presentation" class="table table-striped"><tbody class="files"></tbody></table>
                        </form>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $('.fileupload').fileupload();
</script>